package Delete;

import java.util.Scanner;

public class Delete {
    public static void main(String[] args) {
        //创建三个数组分别储存学生姓名、学号、年龄
        String student[] = new String[3];//储存学生对象
        int studentNumber[] = new int[3];//储存学生学号
        int age[]= new int[3];//储存学生年龄
    }
    //创建一个类判断学号是否存在
    public static void Delete(String student[],int studentNumber [],int age[]){
        Scanner scan = new Scanner(System.in);
        System.out.println("请输入想要删除的学生信息的学号");
        int id = scan.nextInt();
        boolean flag = true;
        for (int i=0;i< student.length;i++){
            if (id!=studentNumber[i]){
                flag = true;
            }else {
                flag = false;
                student[i] = null;
                studentNumber [i] = 0;
                age [i] = 0;
                break;
            }
        }
        if(flag==true){
            System.out.println("学号不存在，删除失败");
        }else {
            System.out.println("学号存在删除成功");
        }
        for (int i=0;i<student.length;i++){
            if (student[i]==null&&studentNumber[i]==0&&age[i]==0){
                continue;
            }
            System.out.println("学生姓名为："+student[i]+" 学号为："+studentNumber[i]+" 年龄为："+age[i]);
            
        }
    }

}
